<?php
namespace app\common\command;

use think\console\Command;
use think\console\Input;
use think\console\input\Argument;
use think\console\input\Option;
use think\console\Output;

// php think tt

class Hello extends Command
{
    protected function configure()
    {
        $this->setName('tt')
            ->addArgument('name', Argument::OPTIONAL, "your name")
            ->addOption('city', null, Option::VALUE_REQUIRED, 'city name')
            ->setDescription('Say Hello');
    }

    protected function execute(Input $input, Output $output)
    {
    	$name = trim($input->getArgument('name'));
      	$name = $name ?: 'thinkphp';

		if ($input->hasOption('city')) {
        	$city = PHP_EOL . 'From ' . $input->getOption('city');
        } else {
        	$city = 'city';
        }

        print_r([$city]);

        // 视频 通知
        // $info   = json_decode('{
        //     "vname": "1",
        //     "vtype": "mp4",
        //     "type": "Video",
        //     "vcode": "",
        //     "totype": [
        //         "mp4",
        //         "avi",
        //         "flv"
        //     ],
        //     "file": "http://eyszyxt.fractaltest.cn/Uploads/Tus/ad/be/44/1.mp4",
        //     "item_id": "1049",
        //     "web_url": "http://eyszyxt.fractaltest.cn",
        //     "numds": null,
        //     "water": {
        //         "img": "http://eyszyxt.fractaltest.cn/Uploads/Picture/2020/02/05/s5e3aadcbe0967.png",
        //         "bottom": "50",
        //         "right": "50"
        //     },
        //     "img": "img/5e5dd02c093bb.jpg",
        //     "zh": [
        //         "Uploads/Tus/ad/be/44/1-360.mp4",
        //         "Uploads/Tus/ad/be/44/1-360.avi",
        //         "Uploads/Tus/ad/be/44/1-360.flv"
        //     ],
        //     "files": [
        //         "http://eyszyxt.fractaltest.cn/Uploads/Tus/ad/be/44/1.mp4",
        //         "Uploads/Tus/ad/be/44/1.avi",
        //         "Uploads/Tus/ad/be/44/1.flv"
        //     ],
        //     "rewater": [
        //         "Uploads/Tus/ad/be/44/1-water.mp4"
        //     ],
        //     "status": 2,
        //     "code": 100,
        //     "status_msg": "任务完成"
        // }',true) ;
        // ( new \app\index\model\Notice )->process($info);

        //视频 转码
        $info   = json_decode('{
            "numds": null,
            "vcode": "",
            "item_id": "1129",
            "type": "Video",
            "web_url": "http://eys.fractalbj.com/",
            "file": "http://eys.fractalbj.com//Uploads/Tus/6b/4f/71/show.mp4",
            "vtype": "mp4",
            "vname": "show",
            "water": {
                "img": "http://eys.fractalbj.com//Uploads/Picture/2020/02/05/s5e3aadcbe0967.png",
                "bottom": "50",
                "right": "50"
            },
            "totype": [
                "mp4",
                "avi",
                "flv"
            ],
            "status": 0,
            "code": 0,
            "status_msg": "任务创建成功"
        }',true) ;
        print_r('222');
        //$info['item_id']    =   time();
        ( new \app\index\model\Video )->process($info);

        // 视频测试转换
        // $info = [
        //     'vname'  => '1' ,
        //     'vtype'  => 'flv' ,
        //     'vcode'  => '' ,
        //     'totype' => ['mp4'] ,    // 转换到的格式
        //     'file'   => '/www/think/1.flv', // 或者文件url
        //     'item_id'=> time(),
        // ] ;
        // ( new \app\index\model\Video )->process($info);

        // 音频测试转换
        // $info = [
        //     'vname'  => '3' ,
        //     'vtype'  => 'wav' ,
        //     'vcode'  => '' ,
        //     'totype' => ['ogg','flac'] ,    // 转换到的格式
        //     'file'   => '/www/think/3.wav', // 或者文件url
        //     'item_id'=> '299',
        // ] ;
        // ( new \app\index\model\Audio )->process($info);

        // // 视频
        // $file       = 'http://www.fractal.com/Uploads/Tus/d8/e1/4b/m-libfdk_aac-X264.flv' ;
        // $ffprobe    = \FFMpeg\FFProbe::create();
        // $durations  = $ffprobe->format($file);
        // $duration   = $durations->get('duration');
        // print_r( [$duration] );
        // // 视频
        // $videos     = $ffprobe->streams( $file )->videos()->first();
        // $width      = $videos->get('width');
        // $height     = $videos->get('height');
        // print_r( [$width,$height] );
        // //音频
        // $audios     = $ffprobe->streams( $file )->audios()->first();
        // $codec_name = $audios->get('codec_name');
        // print_r( [$codec_name] );


        // 测试 通知客户端
        // $info = json_decode('{
        //     "vname": "123149050220e142115951230",
        //     "vtype": "mp4",
        //     "type": "Video",
        //     "vcode": "",
        //     "totype": [
        //         "mp4",
        //         "avi",
        //         "flv"
        //     ],
        //     "file": "http://eyszyxt.club:81/Uploads/Tus/17/9a/ad/123149050220e142115951230.mp4",
        //     "item_id": "1",
        //     "web_url": "http://eyszyxt.club:81",
        //     "numds": null,
        //     "water": {
        //         "img": "http://eyszyxt.club:81/Uploads/png7.png",
        //         "bottom": "50",
        //         "right": "50"
        //     },
        //     "img": "img/5e3a4a7866c0f.jpg",
        //     "zh": [
        //         "Uploads/Tus/17/9a/ad/123149050220e142115951230-360.mp4",
        //         "Uploads/Tus/17/9a/ad/123149050220e142115951230-360.avi",
        //         "Uploads/Tus/17/9a/ad/123149050220e142115951230-360.flv"
        //     ],
        //     "files": [
        //         "http://eyszyxt.club:81/Uploads/Tus/17/9a/ad/123149050220e142115951230.mp4",
        //         "Uploads/Tus/17/9a/ad/123149050220e142115951230.avi",
        //         "Uploads/Tus/17/9a/ad/123149050220e142115951230.flv"
        //     ],
        //     "rewater": [
        //         "Uploads/Tus/17/9a/ad/123149050220e142115951230-water.mp4"
        //     ],
        //     "status": 2,
        //     "code": 100,
        //     "status_msg": "任务完成"
        // }',true);

        // $file       = $info['file'] ;
        // $ffprobe    = \FFMpeg\FFProbe::create();
        // $durations  = $ffprobe->format($file);
        // $duration   = $durations->get('duration');
        // // 视频
        // $videos     = $ffprobe->streams( $file )->videos()->first();
        // $width      = $videos->get('width');
        // $height     = $videos->get('height');

        // $client = new \Hprose\Http\Client( $info['web_url'].'/mdresource/rpcHprose',false );
        // $result = $client->init('update_video', [
        //     $info['files'] ,
        //     $info['item_id'] ,
        //     [
        //         'other' => [
        //             'duration'  => $duration ,
        //             'width'     => $width ,
        //             'height'    => $height ,
        //             'imgs'      => [
        //                 $info['img']
        //             ] ,
        //         ]
        //     ],
        //     $info['file'] ,
        //     $info['zh'] ,
        // ]);
        // print_r(['rpc',$result]);



        // $client = new \Hprose\Http\Client( $info['web_url'].'/mdresource/rpcHprose',false );
        // $result = $client->init('update_video', [ $info['files'] , $info['item_id'] ] );
        // print_r(['rpc',$result]);

        // // 测试 通知客户端
        // $info['files']      = [
        //     'http://www.fractal.com/Uploads/Tus/a4/e6/ed/m.mp4',
        //     'ss/m-libfdk_aac-X264.3gp',
        //     'ss/m-libvorbis-Ogg.ogg',
        // ] ;
        // $info['item_id']    = 1 ;
        // $info['web_url']    = 'http://www.fractal.com' ;

        // $client = new \Hprose\Http\Client( $info['web_url'].'/mdresource/rpcHprose',false );
        // $result = $client->init('update_video', [ $info['files'] , $info['item_id'] ] );
        // print_r(['rpc',$result]);

        // // rpc 测试
        // $client = new \Hprose\Http\Client('http://www.fractal.com/mdresource/rpcHprose',false);
        // $result = $client->test('xxx');
        // print_r(['rpc',$result]);

        // $client = new \Hprose\Http\Client('http://192.168.200.100:8001/api/s',false);
        // $result = $client->test('2222');
        // print_r(['rpc',$result]);  

        //$output->writeln("Hello," . $name . '!' . $city);
    }
}